<style>
    .demo-drawer-profile{
        font-size: 14px;
    }
    .demo-drawer-profile .ivu-col{
        margin-bottom: 50px;
    }
</style>
<template>
	<div>
		<Modal v-model="modalShow" :closable='false' :mask-closable=false fullscreen>
			<p slot="header">审核车辆</p>
			 <div class="demo-drawer-profile">
			    <Row>
                    <Col span="12">
                        	车辆：<span>{{formData.car_brand_name}} {{formData.car_sys_name}} {{formData.car_type_name}}</span>
                    </Col>
                    <Col span="12">
                        	车牌号：<span>{{formData.car_sn}}</span>
                    </Col>
                    <Col span="12">
                        	网点：<span>{{formData.dot_name}}</span>
                    </Col>
                    <Col span="12">
                        	价格：<span>{{formData.d_price}}/天   {{formData.h_price}}/小时</span>
                    </Col>
                    <Col span="12">
                        	不计免赔：<span>{{formData.set_no_ded}}</span>
                    </Col>
                    <Col span="12">
                        	保证金：<span>{{formData.b_price}}</span>
                    </Col>
                    <Col span="12">
                        	随车驾驶员服务：<span>{{formData.is_dri_text}}</span>
                    </Col>
                    <Col span="12">
                        	类型：<span>{{formData.car_class_text}}</span>
                    </Col>
                    <Col span="12">
                        	排量：<span>{{formData.car_out_text}}</span>
                    </Col>
                    <Col span="12">
                        	变速箱：<span>{{formData.car_gear_text}}</span>
                    </Col>
                    <Col span="12">
                        	车辆识别码后四位：<span>{{formData.vin_sn}}</span>
                    </Col>
                    <Col span="12">
                        	发动机号后四位：<span>{{formData.engine_sn}}</span>
                    </Col>
                    <Col span="12">
                        	车辆照片<span v-for="v in formData.car_img_list"><img :src="v" width="100px" height="100px" style="margin-left: 5px;" @click="nImg($event)"></span>
                    </Col>
                    <Col span="12">
                        	人车合照：<span><img :src="formData.car_img" width="100px" height="100px" @click="nImg($event)"></span>
                    </Col>
                    <Col span="12">
                        	行驶证：<span>
                        		 <img :src="formData.drive_z_img" width="100px" height="100px" style="margin-right: 5px;" @click="nImg($event)">
                        		 <img :src="formData.drive_f_img" width="100px" height="100px" @click="nImg($event)">
                        	     </span>
                    </Col>
                </Row>
			 </div>

			<div slot="footer">
				<Button type="text" @click="cancel">取消</Button>
				<Button type="error" @click="refuse" v-if="formData.apply_status == 1">拒绝</Button>
				<Modal v-if="formData.apply_status == 1"
			        v-model="rModel"
			        title="拒绝理由"
			        @on-ok="r_ok"
			        @on-cancel="r_cancel">
			        <Input v-model="formData.un_remark" type="textarea" :autosize="{minRows: 2,maxRows: 5}"></Input>
    			</Modal>
				<Button type="primary" @click="edit" :loading='saveLoading' v-if="formData.apply_status == 1">同意 </Button>
			</div>
		</Modal>

	</div>
</template>
<script>
	import {
		getInfo,
		applyCar
	} from '@/api/cusercar'

	//import Editor from '_c/editor'
	//import Upload from '_c/common/upload'
	export default {
		components: {
			//  Editor,
			//  Upload
		},
		props: {
			modalId: {
				type: Number,
				default: 0
			}
		},
		created() {
			let t = this;
			if(this.modalId > 0) {
				this.getInfoById()
			}
		},
		data() {
			let t = this;
			return {
				modalShow: true,
				saveLoading: false,
				rModel:false,
				formData: {
					car_id:'',
					car_brand_name:'',
					car_sys_name:'',
					car_type_name:'',
					car_sn: '',
					dot_name:'',
					car_class_text: '',
					car_oil_text: '',
					car_out_text: '',
					car_gear_text: '',
					vin_sn: '',
					engine_sn: '',
					drive_z_img: '',
					drive_f_img: '',
					car_img: '',
					d_price: '',
					h_price: '',
					b_price: '',
					car_img_list:'',
					set_no_ded: '',
					is_dri_text: '',
					apply_status:'',
					
					//提交数据
					un_remark:''
				},
			}
		},
		methods: {
			getInfoById() {
				let t = this
				getInfo(t.modalId).then(res => {
					//console.log(res);
					if(res.data.code == 1){
						let res_data = res.data.data;
					    t.formData =  {
					    	car_id:res_data.car_id,
					    	car_brand_name:res_data.car_brand_name,
							car_sys_name:res_data.car_sys_name,
							car_type_name:res_data.car_type_name,
							car_sn: res_data.car_sn,
							dot_name:res_data.dot_name,
							car_class_text: res_data.car_class_text,
							car_oil_text: res_data.car_oil_text,
							car_out_text: res_data.car_out_text,
							car_gear_text: res_data.car_gear_text,
							vin_sn: res_data.vin_sn,
							engine_sn: res_data.engine_sn,
							drive_z_img: res_data.drive_z_img,
							drive_f_img: res_data.drive_f_img,
							car_img: res_data.car_img,
							d_price: res_data.d_price,
							h_price: res_data.h_price,
							b_price: res_data.b_price,
							car_img_list:res_data.car_img_list,
							set_no_ded: res_data.set_no_ded,
							is_dri_text: res_data.is_dri_text,
							apply_status:res_data.apply_status
						}
					    
					}else{
						t.$Notice.error({
							title: res.data.msg
						})
						this.$emit('on-edit-modal-hide')
						this.modalShow = false
					}
					
				})

			},
			edit() {
				this.changeStatusExcute(this.formData.car_id,2)
			},
			refuse(){
				this.rModel =true;
			},
			cancel() {
				this.$emit('on-edit-modal-hide')
				this.modalShow = false
			},
			r_ok(){
				this.changeStatusExcute(this.formData.car_id,-1,this.formData.un_remark)
			},
			r_cancel(){
				//清空
				this.formData.un_remark='';
			},
			changeStatusExcute(car_id,apply_status,un_remark=''){
				let t = this;
                let params ={
                	'car_id':car_id,
                	'apply_status':apply_status,
                	'un_remark':un_remark
                }
				applyCar(params).then(res => {
							if(res.data.code == 1) {
								t.saveLoading = false
								t.modalShow = false
								t.$emit('on-edit-modal-success')
								t.$emit('on-edit-modal-hide')
								t.$Notice.success({
									title: res.data.msg
								})
							} else {
								t.saveLoading = false
								t.$Notice.error({
									title: res.data.msg
								})
							}

						}, function(error) {
							t.saveLoading = false
				})
			},
			nImg(e){
				let imgUrl = e.target.getAttribute('src');
				window.open(imgUrl); 
			}	
			
		},

	}
</script>